<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <f:view contentType="text/html">    
        <h:head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title><ui:insert name="title">VFriends Games</ui:insert></title>
            <style type="text/css">
                .ui-widget {
                    font-family: Tahoma;
                    font-size: 11.5px;
                }
            </style>
        </h:head>
        <h:body>
            <h:outputStylesheet library="css" name="component.css"/>
            <h:outputStylesheet library="css" name="mainLayout.css"/>
            <ui:insert name="idleMonitor">
                <h:form id="monitorForm" prependId="false">
                    <p:idleMonitor timeout="#{session.maxInactiveInterval * 1000}" onidle="idleDialog.show();" 
                                   onactive='window.location = "#{request.contextPath}/home.jsf";'/>

                    <p:dialog header="Thông báo" resizable="false" widgetVar="idleDialog" modal="true" width="400">
                        <h:outputText value="Phiên làm việc đã hết hạn" />
                    </p:dialog>
                </h:form>
            </ui:insert>

            <div id="container">
                <div id="header">
                    <h:form id="headerForm" prependId="false">
                        <h:panelGrid columns="2" width="100%">
                            <h1 style="color: white;">
                                VFriends Games
                            </h1>
                            <h:panelGroup style="margin-right: 10px; float: right;">
                                <h:panelGrid columns="1" rendered="#{securityBean.loggedUser != null}">
                                    <p:menuButton value="#{securityBean.loggedUser.fullName == '' || securityBean.loggedUser.fullName == null ? securityBean.loggedUser.username : securityBean.loggedUser.fullName}">
                                        <p:menuitem url="http://id.vfriends.vn/account/profile.jsf" value="Thông tin tài khoản"/>
                                        <p:menuitem action="#{securityBean.logoutAction()}" ajax="false" value="Đăng xuất"/>
                                    </p:menuButton>
                                </h:panelGrid>
                                
                                <p:menuButton value="Đăng nhập" rendered="#{securityBean.loggedUser == null}">  
                                    <p:menuitem value="Google" action="#{openIdBean.selectOPAction}" ajax="false">
                                        <f:param name="identifier" value="https://www.google.com/accounts/o8/id" />
                                    </p:menuitem>  
                                    <p:menuitem value="Yahoo" action="#{openIdBean.selectOPAction}" ajax="false">
                                        <f:param name="identifier" value="https://me.yahoo.com" />
                                    </p:menuitem>  
                                    <p:menuitem value="VFriends ID" action="#{openIdBean.selectOPAction}" ajax="false">
                                        <f:param name="identifier" value="http://id.vfriends.vn/op" />
                                    </p:menuitem>
                                </p:menuButton>  
                                <h:outputLink value="http://id.vfriends.vn/register.jsf" style="padding-left: 10px; color: white;" rendered="#{securityBean.loggedUser == null}">
                                    Đăng ký
                                </h:outputLink>
                                <h:outputLink value="http://id.vfriends.vn/forgotpass.jsf" style="padding-left: 10px; color: white;" rendered="#{securityBean.loggedUser == null}">
                                    Quên mật khẩu
                                </h:outputLink>
                            </h:panelGroup>
                        </h:panelGrid>
                    </h:form>
                </div>
                <div id="navigation">
                    <h:form id="menuBarForm">
                        <p:menubar>
                            <p:menuitem value="Trang chủ" url="/home.jsf"/>
                            <p:menuitem value="Game" url="/games.jsf"/>
                            <p:menuitem value="Tin tức - Sự kiện" url="/news.jsf"/>
                            <p:menuitem value="Nạp tiền" url="/payment.jsf"/>
                            <p:menuitem value="Diễn đàn" url="/forum.jsf"/>
                            <p:menuitem value="Quản trị" url="/admin.jsf" 
                                        rendered="#{securityBean.isUserInRole('ADMINISTRATOR') or securityBean.isUserInRole('EDITOR')}"/>
                        </p:menubar>
                    </h:form>
                </div>
                
                <div id="content">
                    <h:form id="statusForm" prependId="false">
                        <p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  

                        <p:dialog modal="false" widgetVar="statusDialog" header="Trạng thái"   
                                  draggable="false" closable="false">  
                            <p:graphicImage value="#{resource['images:ajaxloadingbar.gif']}" />  
                        </p:dialog>
                    </h:form>

                    <p:panel>
                        <ui:insert name="content"></ui:insert>
                    </p:panel>
                </div>
                
                <div id="footer" style="color: white;">
                    Copyright © VFriends, 2012
                </div>
            </div>
        </h:body>
    </f:view>    
</html>
